#ifndef _MIX_THREAD_SEMAPHORE_H_
#define _MIX_THREAD_SEMAPHORE_H_

namespace mix
{

class Semaphore
{
public:
    Semaphore();
    ~Semaphore();

    enum {
        DefMaxCount = -1,
    };

    bool init( int initCount = 0, int maxCount = DefMaxCount);
    void close();
    
    void wait();
    bool tryWait();
    bool tryWait( long msec);

    bool post();

    void* getNative();

private:
    Semaphore( const Semaphore&);
    Semaphore& operator=( const Semaphore&);

    void* _impl;
};

}   // namespace mix

#endif // _MIX_THREAD_SEMAPHORE_H_
